import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // CSS重置的现代替代方案

import Element from 'element-ui'
import '@/styles/index.scss' // global css
import jsoneditor from 'jsoneditor'

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import axios from 'axios'

import './icons' // icon
import './permission' // 许可控制
import './utils/error-log' // error log

import * as filters from './filters'
import _ from 'lodash'
import NProgress from 'nprogress'
import { register, themeSet } from './globalRegister' // 全局组件注册
NProgress.configure({ showSpinner: false }) // N
/**
 * 如果你不想使用mock-server
 * 你想使用mockjs进行请求拦截
 * 你可以执行：
 *
 * import { mockXHR } from '../mock'
 * mockXHR()
 */
// 设置全局的请求次数，请求的间隙
axios.defaults.retry = 4
axios.defaults.retryDelay = 1000
Vue.prototype.$http = axios
Vue.prototype.Loading = Element.Loading
Vue.prototype.$progress = NProgress
Vue.prototype.$jsoneditor = jsoneditor
Vue.prototype._ = _
Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})

// 注册全局实用过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
// 全局组件注册 样式设置
Vue.nextTick(function() {
  register(Vue)
  themeSet()
})

